import axios from '../../utils/request';

/**
 * 模块名:班级
 */

// 创建
export interface StudentCreatedType {
  studentNumber: string;
  s_name: string;
  s_address: string;
  gender: number;
  department_id: number;
  major_id: number;
}

export function created(data: StudentCreatedType) {
  return axios.request({
    url: '/student',
    method: 'post',
    data,
  });
}

// 列表
export interface StudentSearchType {
  page: number;
  limit: number;
  name?: string;
  blur?: string;
  studentNumber?: string;
}
export function list(params: StudentSearchType) {
  return axios.request({
    url: '/student',
    method: 'get',
    params,
  });
}

// 详情
export function detail(id: number) {
  return axios.request({
    url: '/student/' + id,
    method: 'get',
  });
}

// 更新
export function update(id: number, data: StudentCreatedType) {
  return axios.request({
    url: '/student/' + id,
    method: 'patch',
    data,
  });
}

// 删除
export function del(id: number) {
  return axios.request({
    url: '/student/' + id,
    method: 'delete',
  });
}

export default {
  created,
  list,
  detail,
  update,
  del,
};
